package com.lsu.app.mapper;

import com.lsu.app.bean.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 *
 * @description 针对表【comment(评论)】的数据库操作Mapper
 * @Date 2023-10-18 20:25:44
 * @author hjj
 */
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {

    @Update("update comment set heat = heat + #{amount} where id=#{id}")
    void addHeatById(@Param("id") Integer id, @Param("amount") Integer amount);//热度
    @Select("select teacher_id from course where id=#{courseId}")
    Integer getTeacherIdByCourseId(Integer courseId);//课程id获取教师id
    @Select("select teacher_id from course where id=(select uorr_id from resource where resource.id=#{id})")
    Integer getUserIdByCourseVideoId(Integer id);//通过课程视频获取教师id
    @Select("select count(*) from comment where type=#{type} and link_id=#{linkId}")
    Integer getCountByTypeAndLinkId(@Param("type") Integer type ,@Param("linkId") Integer linkId);//获取回复数
    @Select("select count(*) from comment where target_user_id=#{teacherId}")
    Integer CountCommentsByTeacherId(Integer teacherId);//根据教师id获取被评论数

}




